package com.zx.ce.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zx.ce.mapper.OrderMapper;
import com.zx.ce.pojo.OrderModel;
import com.zx.ce.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/web")
public class OrderWeb {

    @Resource
    private OrderService orderService;
    
    @Resource
    private OrderMapper orderMapper;


    @PostMapping("/updateMapper")
    public void updateMapper(){
        orderMapper.update(null, Wrappers.<OrderModel>lambdaUpdate()
                .eq(OrderModel::getId,8).set(OrderModel::getUserId,"ddd"));

        OrderModel model = new OrderModel();
        model.setUserId("666666");
        orderMapper.update(model, Wrappers.<OrderModel>lambdaUpdate()
                .eq(OrderModel::getId,8));
                
    }

    @PostMapping("/add")
    public Long createOrder(@RequestBody OrderModel order){
        Long orderId = orderService.create(order);
        return orderId;
    }

    @GetMapping("/list")
    public List<OrderModel> getList(){
        List<OrderModel> list = orderService.list();
        return list;
    }
    @PostMapping
    private String testEnableBindingAnno(){
        return orderService.testEnableBindingAnno();
    }
}
